#include <bits/stdc++.h>
using namespace std;
struct TreeNode {
	int val;
	TreeNode *left;
	TreeNode *right;
	TreeNode() : val(0), left(nullptr), right(nullptr) {}
	TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
	TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
};

class Test01{
public:
	TreeNode* searchBST(TreeNode* root, int val) {
		if(root == NULL || root->val == val){
			return root;
		}
		if(val < root->val){
			return searchBST(root->left,val);
		}
		if(val > root->val){
			return searchBST(root->right,val);
		}
	}
};
class Test02{
public:
	TreeNode* searchBST(TreeNode* root, int val) {
		TreeNode* cur = root;
		while(cur != NULL){
			if(val < cur->val){
				cur = cur->left;
			}else if(val > cur->val){
				cur = cur->right;
			}else{
				return cur;
			}
		}
		return cur;
	}
};
class Solution {
public:
	TreeNode* mergeTrees(TreeNode* t1, TreeNode* t2) {
		if (t1 == NULL) return t2; // 如果t1为空，合并之后就应该是t2
		if (t2 == NULL) return t1; // 如果t2为空，合并之后就应该是t1
		// 修改了t1的数值和结构
		t1->left = mergeTrees(t1->left, t2->left);      // 左
		t1->right = mergeTrees(t1->right, t2->right);   // 右
		t1->val += t2->val;                             // 中
		return t1;
	}
};

int main(){
	
	return 0;
}
